package com.atguigu02.method_lifecycle;
/*模拟新年倒计时，每隔1秒输出一个数字，依次输出10,9,8..T，最后
        输出:新年快乐!*/

public class t {
    public static void main(String[] args) {
        Print p1=new Print();
        p1.start();

    }
}

class Print extends Thread{
    static int s=10;
    @Override
    public void run() {
        while (true){
            if(s>0){
                try {
                Thread.sleep(1000);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
                System.out.println(s);
                s--;
            }else{
                try {
                    Thread.sleep(1000);
                }catch (InterruptedException e){
                    e.printStackTrace();
                }
                System.out.println("happy new year");
                break;
            }
        }
    }
}
